Primary exercises

Create tibble

  1. Create a tibble exercise_group for a group of individuals with names {Sonja, Steven, Ines, Robert, Tim} with their heights {164, 188, 164, 180, 170}, weights {56.0, 87.0, 54.0, 80.0, 58.5} and frequency of exercise {high, high, low, moderate, low}.

tibble subset

  1. Take the tibble exercise_group from the previous exercise and create a new tibble without the height and weight variables.

Extract variables as vectors

  1. Given the tibble favourite_colour, how old were the subjects by the end of 2019?

  2. What is the mean height in exercise_group? Use mean function (see ?mean).

Read tibbles from file

  1. Read pulse.csv data set into R and inspect its dimensions.

  2. Read survey.csv data set into R.

  • Inspect the dimensions.

  • Show the first 9 and the last 7 rows.

  • Calculate the mean age.

  • Calculate the mean height in survey data.

Extra exercises

In survey data:

  1. What is the mean height of the last 30 observations?

  2. What is the mean height of the joint first 15 and last 30 observations?

  3. Make a tibble where the variable age comes directly after name.

  4. Given favourite_colour1:

favourite_colour1  <- tibble(name=c("Lucas","Lotte","Noa","Wim"), 
                           year=c(1995,1995,1995,1994), 
                           colour=c("Blue","Green","Yellow","Purple"))
favourite_colour1
# A tibble: 4 x 3
  name   year colour
  <chr> <dbl> <chr> 
1 Lucas  1995 Blue  
2 Lotte  1995 Green 
3 Noa    1995 Yellow
4 Wim    1994 Purple

4.1 Add Isaac with age 23.

4.2 Include heights 175 and 183 for Lotte and Lucas respectively.



Copyright © 2021 Biomedical Data Sciences (BDS) | LUMC